#include "headfiles.h"

using namespace std;

int main(int argc, char **argv) {
    if (argc != 2) {
        cout << "Usage: " << argv[0] << " file" << endl;
        return 0;
    }

    vector<int> input_array;
    fstream fs;
    fs.open(argv[1], iostream::in);
    if (!fs.is_open()) {
        cout << "File " << argv[1] << " open error!" << endl;
        return 1;
    }

    string str;
    while (fs >> str) {
        if (str.empty()) {
            break;
        }

        int val = atoi(str.c_str());
        input_array.push_back(val);
    }
    fs.close();

    int start, end, max_dist;
    max_dist = maxDistance(input_array, start, end);

    cout << "Max distance = " << max_dist << endl;
    cout << "(start, end) = (" << start << ", " << end << ")" << endl;

    return 0;
}
